home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume20 / deliver2.0 / part01 next >
Encoding:
Internet Message Format  |  1989-10-15  |  36.8 KB

  1. Subject:  v20i023:  Deliver, flexible email delivery system, Part01/04
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: Chip Salzenberg <chip@ateng.com>
  7. Posting-number: Volume 20, Issue 23
  8. Archive-name: deliver2.0/part01
  9.  
  10. Deliver is a program which delivers electronic mail once it has arrived
  11. at a given machine.  It is intended for use in three environments:
  12.     1.  Any Xenix system.
  13.     2.  Any Unix system with smail 2.x.
  14.     3.  Any Unix system with either sendmail or smail 3.x.
  15.  
  16. If you have been frustrated by inflexible E-Mail delivery, here is your
  17. salvation.  Deliver permits complete control over mail delivery through
  18. the use of "delivery files."  Delivery files are shell scripts which are
  19. executed during message delivery.  These shell scripts -- written by you!
  20. -- control who, if anyone, gets each E-Mail message.
  21.  
  22. Mostly, Deliver 2.0 is an incremental enhancement from Deliver 1.0.8.  New
  23. features include:
  24.     1.  Parsing of the From_ line.  Badly formed From_ lines, including
  25.         those with illegal dates, are rejected.  Messages with invalid From_
  26.         lines are still delivered, but the contents the From_ line is
  27.     put into an Invalid-UUCP-From: line.
  28.  
  29.     2.  The "header" program, which parses RFC822 headers.  Besides its
  30.         obvious utility in delivery files, header should prove quite useful
  31.         for scanning Usenet directories.
  32.  
  33.     3.  Sample delivery files, including the often-requested vacation
  34.     "answering machine".
  35.  
  36. -- 
  37. Chip Salzenberg                   <chip@ateng.com> or <uunet!ateng!chip>
  38. A T Engineering                     "Designed with your mind in mind."
  39.  
  40. #! /bin/sh
  41. # This is a shell archive.  Remove anything before this line, then unpack
  42. # it by saving it into a file and typing "sh file".  To overwrite existing
  43. # files, type "sh file -c".  You can also feed this as standard input via
  44. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  45. # will see the following message at the end:
  46. #        "End of shell archive."
  47. # Contents:  README deliver.8 Makefile uid.c header.c getopt.c samples
  48. #   samples/README samples/p-aliases samples/s-aliases samples/u-chip
  49. #   samples/u-vacation
  50. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  51. if test -f 'README' -a "${1}" != "-c" ; then 
  52.   echo shar: Will not clobber existing file \"'README'\"
  53. else
  54. echo shar: Extracting \"'README'\" \(2335 characters\)
  55. sed "s/^X//" >'README' <<'END_OF_FILE'
  56. X$Header: README,v 2.1 89/06/09 12:25:10 network Exp $
  57. X
  58. X
  59. X                             WHAT IS DELIVER?
  60. X
  61. X
  62. XDeliver is a program which delivers electronic mail once it has arrived
  63. Xat a given machine.
  64. X
  65. X
  66. X
  67. X                              WHO CAN USE IT?
  68. X
  69. X
  70. XDeliver is intended for use in three environments:
  71. X
  72. X
  73. X    1.  Any Xenix system.
  74. X
  75. X        Deliver was invented to be a direct replacement for the Xenix
  76. X        program /usr/lib/mail/mail.local.  In fact, on ateng, mail.local is
  77. X    just another link to /usr/bin/deliver.
  78. X
  79. X
  80. X    2.  Any Unix system with smail 2.x.
  81. X
  82. X        You can use deliver for local mail by changing the local mailer
  83. X        definition in config.h:
  84. X        #define LMAIL(frm)      "/usr/bin/deliver -r '%s'",frm
  85. X
  86. X
  87. X    3.  Any Unix system with either sendmail or smail 3.x.
  88. X
  89. X    Any user can let deliver handle all his mail by putting the
  90. X    following line in his .forward file:
  91. X        "|/usr/bin/deliver username"
  92. X    Be sure to specify the correct username, or someone else will
  93. X    get your mail!
  94. X
  95. X
  96. X
  97. X                                PORTABILITY
  98. X
  99. X
  100. XDeliver has been compiled and tested under SCO Xenix System V/286 and 4.3
  101. XBSD.  The configuration provides for System V, but I have not been able to
  102. Xtest it. (Patches for all environments are welcome; see below.)
  103. X
  104. X
  105. X
  106. X               WARNINGS: BE CAREFUL!
  107. X
  108. X
  109. X    1.  Deliver is intended to be run setuid root; otherwise it would not
  110. X        be possible to execute a user delivery file in the context of its
  111. X        owner.  Any setuid root program is a potential security hole!  Be
  112. X        careful of the modes on the deliver binary and the directory where
  113. X        it lives.
  114. X
  115. X    2.  Deliver's flexibility makes it easy to lose lots of mail through
  116. X    carelessness in configuration.  Delivery files should be written
  117. X    with extreme care.
  118. X
  119. X
  120. X
  121. X                          COMPILING AND INSTALLING
  122. X
  123. X
  124. XEdit the Makefile and config.h to taste.  Type "make".  To install, type
  125. X"make install".  See the Makefile for further hints.
  126. X
  127. X
  128. X
  129. X                HELP SAVE THE WORLD!
  130. X
  131. X
  132. XIf you run into a bug, you are probably not alone.  Save your fellow human
  133. Xbeings from toil and trouble!  Send mail to <bugs-deliver@ateng.uucp>.  Bug
  134. Xreports accepted; patches greatly appreciated.  I will coordinate patches.
  135. X
  136. XThank you, and good night.
  137. X
  138. X    Chip Salzenberg
  139. X    A T Engineering
  140. X
  141. X    <chip@ateng.uucp> or
  142. X    <chip@ateng.uu.net> or
  143. X    <uunet!ateng!chip>
  144. END_OF_FILE
  145. if test 2335 -ne `wc -c <'README'`; then
  146.     echo shar: \"'README'\" unpacked with wrong size!
  147. fi
  148. # end of 'README'
  149. fi
  150. if test -f 'deliver.8' -a "${1}" != "-c" ; then 
  151.   echo shar: Will not clobber existing file \"'deliver.8'\"
  152. else
  153. echo shar: Extracting \"'deliver.8'\" \(11359 characters\)
  154. sed "s/^X//" >'deliver.8' <<'END_OF_FILE'
  155. X.\" $Header: deliver.8,v 2.1 89/06/09 12:25:19 network Exp $
  156. X.\"
  157. X.\" Man page for deliver.
  158. X.\"
  159. X.\" $Log:    deliver.8,v $
  160. X.\" Revision 2.1  89/06/09  12:25:19  network
  161. X.\" Update RCS revisions.
  162. X.\" 
  163. X.\" Revision 1.8  89/06/09  12:23:42  network
  164. X.\" Baseline for 2.0 release.
  165. X.\" 
  166. X.TH DELIVER 8
  167. X.SH NAME
  168. Xdeliver \- deliver local mail
  169. X.SH SYNOPSIS
  170. X.B deliver
  171. X[ options ] address ...
  172. X.SH DESCRIPTION
  173. XThe
  174. X.I deliver
  175. Xprogram collects a mail message from the standard input and delivers it.
  176. XIt is intended to take over the delivery of all local mail, a job usually
  177. Xhandled by
  178. X.I /bin/mail
  179. X(System V),
  180. X.I /usr/lib/sendmail
  181. X(BSD), or
  182. X.I /usr/lib/mail/mail.local
  183. X(Xenix).
  184. X.PP
  185. X.I deliver
  186. Xintroduces flexibility in the handling of local mail delivery.  All files
  187. Xused to control
  188. X.I deliver
  189. Xare Bourne shell scripts.  Thus anything that can be called by a shell
  190. Xscript can be used to control mail delivery.
  191. X.SH OPTIONS
  192. X.TP
  193. X.B \-b
  194. XInterpret all arguments as mailbox filenames instead of addresses.  Note
  195. Xthat the user running
  196. X.I deliver
  197. Xmust have write permissions on the given mailbox files.  He may also need
  198. Xwrite permissions on their parent directories, depending on the existence
  199. Xof the mailbox file and the local locking protocol.
  200. X.TP
  201. X.B \-n
  202. XInterpret arguments as addresses, but do not run any delivery files; simply
  203. Xdeliver the message to the mailbox(es) of the given user(s).  This option is
  204. Xmost useful when
  205. X.I deliver
  206. Xis executed recursively, since it prevents further recursion.
  207. X.TP
  208. X.B \-A
  209. XPrint resolved addresses; do not deliver the message.  Note that
  210. X.I deliver
  211. Xstill collects a message from the standard input, since delivery files may
  212. Xdo different things depending on message content.  For simple testing,
  213. Xredirect standard input from /dev/null.
  214. X.TP
  215. X.B \-d
  216. XBe verbose; don't deliver to any mailboxes or catch any signals.
  217. X.TP
  218. X.B \-v
  219. XBe verbose, but still deliver.
  220. X.TP
  221. X.B \-t
  222. XDo not remove temporary files before exiting.
  223. X.TP
  224. X.BI \-r " sender"
  225. XPut
  226. X.I sender
  227. Xon the generated From_ line.  Default is to use the address on the From_
  228. Xline in the input, or else the name corresponding to the real uid, or else
  229. X"unknown".
  230. X.TP
  231. X.BI \-h " hostname"
  232. XSet the host name.  The default is configuration dependent.
  233. X.TP
  234. X.BI \-s " system delivery file"
  235. XSpecify an alternate system delivery file.  The default is
  236. X.I /usr/local/lib/deliver.sys.
  237. XFor security reasons, this option disables setuid privileges.
  238. X.TP
  239. X.BI \-p " post-user delivery file"
  240. XSpecify an alternate post-user delivery file.  The default is
  241. X.I /usr/local/lib/deliver.post.
  242. XFor security reasons, this option disables setuid privileges.
  243. X.TP
  244. X.BI \-u " user delivery file"
  245. XSpecify an alternate user delivery file.  The default is
  246. X.I .deliver
  247. X(in each user's home directory).
  248. XFor security reasons, this option disables setuid privileges.
  249. X.PP
  250. XAll command line options are put into environment variables, examined by
  251. X.I deliver
  252. Xon startup; thus all flags are propagated when
  253. X.I deliver
  254. Xis invoked recursively.
  255. X.SH ENVIRONMENT
  256. XFor mail systems based on
  257. X.I smail
  258. X2.x, the LMAIL (local mailer) macro can be changed to call
  259. X.I deliver.
  260. XFor mail systems based on
  261. X.I smail
  262. X3.x or
  263. X.I sendmail,
  264. Xa similar arrangement may be made; or individual users can invoke
  265. X.I deliver
  266. Xby mentioning it in their
  267. X.I .forward
  268. Xfiles.
  269. X.PP
  270. XFor Xenix systems,
  271. X.I deliver
  272. Xmay be used as a direct replacement for
  273. X.IR /usr/lib/mail/mail.local.
  274. X.PP
  275. XFor stock Unix systems, it may be possible to make
  276. X.I /bin/rmail
  277. Xa link to
  278. X.I deliver;
  279. Xhowever, this configuration has not been tested and is not recommended.
  280. XAny postmaster motivated enough to install
  281. X.I deliver,
  282. Xand who wants something better than the standard
  283. X.I /bin/rmail,
  284. Xshould install
  285. X.I smail.
  286. X.SH OPERATION
  287. XBy default,
  288. X.I deliver
  289. Xdeposits mail in the system mailbox for the named user(s).  Also, as a
  290. Xnecessity for use with
  291. X.I smail
  292. X2.x,
  293. X.I deliver
  294. Xalso understands UUCP-style bang addresses well enough to forward the
  295. Xmessage correctly, using
  296. X.I uux.
  297. X.PP
  298. XHowever, this basic behavior only scratches the surface: the usefulness of
  299. X.I deliver
  300. Xderives from its flexibility; its behavior can be made to depend on the
  301. Xrecipient(s), content or any other aspect of mail messages.
  302. X.PP
  303. XWhen
  304. X.I deliver
  305. Xstarts execution, it interprets its arguments in one of three ways.  If the
  306. X.B \-b
  307. X(mailbox) option was specified, then all arguments are interpreted as
  308. Xmailbox pathnames.  Otherwise, if a system delivery file exists and the
  309. X.B \-n
  310. X(no delivery files) option was not specified,
  311. X.I deliver
  312. Xexecutes the system delivery file with all of deliver's arguments
  313. Xas its arguments.
  314. X.I deliver
  315. Xinterprets the delivery file's output as described below.  This procedure
  316. Xgives the postmaster control over delivery to non-existent hosts and users.
  317. XIf the
  318. X.B \-n
  319. Xoption is specified or if there is no system delivery file,
  320. X.I deliver
  321. Xinterprets all its arguments as mail addresses.
  322. X.PP
  323. XAfter possibly executing the system delivery file,
  324. X.I deliver
  325. Xlooks in its list of destinations for valid user names without explicitly
  326. Xnamed mailboxes.  If any of these users have user delivery files in
  327. Xtheir home directories, and if the
  328. X.B \-n
  329. Xoption was not specified,
  330. X.I deliver
  331. Xexecutes each user delivery file with the name of the given user as its
  332. Xonly argument.
  333. X.PP
  334. XAfter executing any user delivery files,
  335. X.I deliver
  336. Xlooks in its list of destinations for simple user names and UUCP
  337. Xaddresses.  If any are found, if the post-user delivery file exists,
  338. Xand if the
  339. X.B \-n
  340. Xoption was not specified,
  341. X.I deliver
  342. Xexecutes the post-user delivery file with these addresses as its arguments.
  343. X.SH "DELIVERY FILES"
  344. XDelivery files are shell scripts.  They are executed by
  345. X.I deliver
  346. Xto control delivery to users.  Note that delivery files do
  347. X.I not
  348. Xcontrol delivery to explicitly named mailboxes.
  349. X.PP
  350. XOn each system the postmaster may create a
  351. X.I system delivery file
  352. Xto controls delivery of all messages.
  353. XThe system delivery file, if it exists, is executed
  354. Xwith the name(s) specified on the
  355. X.I deliver
  356. Xcommand line as its arguments.
  357. X.PP
  358. XThe postmaster may also create a
  359. X.I post-user delivery file
  360. Xwhich is executed after any user delivery files, but before delivery of the
  361. Xmessage to any mailboxes.  This file is particularly useful for implementing
  362. Xsystem-wide aliases, since it can deal with addresses generated by user
  363. Xdelivery files, whereas the system delivery file cannot.
  364. X.PP
  365. XFinally, each user may create a
  366. X.I user delivery file
  367. Xin his home directory.  User delivery files are always executed with exactly
  368. Xone argument: the name of the user in whose home directory the file is
  369. Xfound.
  370. X.PP
  371. XRecursive execution of
  372. X.I deliver
  373. Xis useful, especially with the
  374. X.B \-b
  375. X(mailbox) and
  376. X.B \-n
  377. X(no delivery files) flags.  For example, a user may wish to transform a
  378. Xmessage body before it is stored in a mailbox.  This may be done with a user
  379. Xdelivery file and recursive execution of
  380. X.I deliver.
  381. XFor example, the following user delivery file translates all incoming
  382. Xmessage bodies to lower case, and stores them in the user's default mailbox:
  383. X.TP
  384. X(cat $HEADER; tr '[A-Z]' '[a-z]' <$BODY) | deliver -n "$1"
  385. X.PP
  386. XWhen
  387. X.I deliver
  388. Xexecutes a delivery file, it sets several environment variables, listed
  389. Xbelow.
  390. XNote that these environment variables are both set and used by
  391. X.I deliver;
  392. Xtherefore, all command line options automatically propagate when
  393. X.I deliver
  394. Xis run recursively (within a delivery file).  The environment variable
  395. Xnames set and used by
  396. X.I deliver
  397. Xare:
  398. X.TP
  399. X.B DELFLAGS
  400. XThe command line flags, if any, specified on the
  401. X.I deliver
  402. Xcommand line.
  403. X.TP
  404. X.B SYSDELFILE
  405. XThe system delivery filename.
  406. X.TP
  407. X.B POSTDELFILE
  408. XThe post-user delivery filename.
  409. X.TP
  410. X.B USERDELFILE
  411. XThe user delivery filename, relative to the home directory of each user.
  412. X.TP
  413. X.B HOSTNAME
  414. XThe local host name, either the real hostname or a name specified with the
  415. X.B \-h
  416. Xoption to
  417. X.I deliver.
  418. X.TP
  419. X.B SENDER
  420. XThe sender, either an address specified with
  421. X.B \-r
  422. Xoption to
  423. X.I deliver,
  424. Xor the address given in the From_ line of the message, or the user who
  425. Xinvoked
  426. X.I deliver.
  427. X.TP
  428. X.B HEADER
  429. XThe name of the temporary file containing the message header.
  430. X.TP
  431. X.B BODY
  432. XThe name of the temporary file containing the message body.
  433. X.PP
  434. X.I deliver
  435. Xmonitors the standard output of delivery files for lines of two forms:
  436. Xeither "user" or "user:mailbox".  Those users whose names appear in the
  437. Xoutput of a delivery file will receive the message.  If a mailbox name
  438. Xappears after the user name, then that mailbox receives the message.  If a
  439. Xmailbox name is not specified, the user's default mailbox is used. (The
  440. Xdefault mailbox for a user is configuration-dependent.) If a mailbox is not
  441. Xan absolute pathname, it is interpreted relative to the home directory of
  442. Xthe named user.
  443. X.PP
  444. X.B NOTE 1:
  445. XWhen
  446. X.I deliver
  447. Xexecutes a delivery file, it expects that delivery file to explicitly name
  448. Xall users (and, optionally, mailboxes) where the message should be
  449. Xdelivered.  If a delivery file does not name any users in its output, then
  450. Xthe message will not be delivered to anyone whose mail delivery is
  451. Xcontrolled by that delivery file.
  452. X.PP
  453. XTherefore, a user delivery file containing only "exit" will keep the given
  454. Xuser from receiving any mail.  A system delivery file containing only "exit"
  455. Xwill cause
  456. X.B all
  457. Xmail to disappear.  So be careful!
  458. X.PP
  459. X.B NOTE 2:
  460. XIf
  461. X.I deliver
  462. Xis setuid root -- which it should be for normal operation -- then the system
  463. Xdelivery file is executed as root.  Be
  464. X.I "very careful"
  465. Xabout its permissions and its contents!  Carelessness here can easily
  466. Xcreate a security problem.
  467. X.PP
  468. X.B NOTE 3:
  469. XAll user delivery files are executed in the context of the user in whose
  470. Xhome directory they reside.  A user's "context" includes the uid, gid, and
  471. Xhome directory as specified in /etc/passwd.
  472. X.PP
  473. X.B NOTE 4:
  474. XFor security reasons, if a user's home directory is writable to the world,
  475. X.I deliver
  476. Xwill ignore any delivery file that might be found there.
  477. X.PP
  478. X.B NOTE 5:
  479. XFor security reasons,
  480. X.I deliver
  481. Xrejects lines of the form "user:mailbox" when generated by a user delivery
  482. Xfile unless they are output by the given user's delivery file.  In other
  483. Xwords, no user can request writing a mailbox as another user.
  484. X.SH LOCKING
  485. XSeveral preprocessor labels may be defined during compilation to control
  486. Xthe method(s) used by
  487. X.I deliver
  488. Xto lock mailboxes.  These labels are:
  489. X.RS
  490. X.PP
  491. X.B ML_DOTLOCK
  492. XLock on exclusive creation of the mailbox name with ".lock"
  493. Xappended.  (Version 7 and early BSD mailers use this method.)
  494. X.PP
  495. X.B ML_DOTMLK
  496. XLock on exclusive creation of
  497. X.I /tmp/basename.mlk,
  498. Xwhere
  499. X.I basename
  500. Xis the last component of the mailbox pathname.  (Xenix mailers use this
  501. Xmethod.)
  502. X.PP
  503. X.B ML_LOCKF
  504. XExclusively lock mailbox with lockf().
  505. X.PP
  506. X.B ML_FCNTL
  507. XExclusively lock mailbox with fcntl().
  508. X.PP
  509. X.B ML_LOCKING
  510. XExclusively lock mailbox with locking().
  511. X.PP
  512. X.RE
  513. XOne or both of ML_DOTLOCK and ML_DOTMLK may be specified.  At most one of
  514. XML_LOCKF, ML_FCNTL or ML_LOCKING may be specified.
  515. X.SH FILES
  516. X/usr/local/lib/deliver.sys      system delivery file
  517. X.br
  518. X/usr/local/lib/deliver.post     post-user delivery file
  519. X.br
  520. X~user/.deliver                  user delivery file(s)
  521. X.br
  522. X/etc/systemid                   system name (Xenix only)
  523. X.SH SUPPORT
  524. XEnhancements, enhancement requests, trouble reports, etc., should be mailed
  525. Xto <bugs-deliver@ateng.com>; or for UUCP-only sites,
  526. X<uunet!ateng!bugs-deliver>.
  527. X.SH "SEE ALSO"
  528. X.IR mail (1),
  529. X.IR uux (1),
  530. X.IR smail (8),
  531. X.IR sendmail (8)
  532. END_OF_FILE
  533. if test 11359 -ne `wc -c <'deliver.8'`; then
  534.     echo shar: \"'deliver.8'\" unpacked with wrong size!
  535. fi
  536. # end of 'deliver.8'
  537. fi
  538. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  539.   echo shar: Will not clobber existing file \"'Makefile'\"
  540. else
  541. echo shar: Extracting \"'Makefile'\" \(4306 characters\)
  542. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  543. X# $Header: Makefile,v 2.2 89/06/09 13:19:53 network Exp $
  544. X#
  545. X# Makefile for deliver
  546. X#
  547. X#  +----------------+
  548. X#  | Things to make |
  549. X#  +----------------+
  550. X#
  551. X#       deliver         Compile and link the deliver program.
  552. X#       header          Compile and link the header program.
  553. X#       install         Install deliver and header.  (You must be root.)
  554. X#       lint            Run lint on all sources, creating lint.out.
  555. X#       shar            Create distribution sharchives.
  556. X#       clean           Clean up.
  557. X#       clobber         Remove everything that can be regenerated.
  558. X#
  559. X#  +---------------+
  560. X#  | Configuration |
  561. X#  +---------------+
  562. X#
  563. X# SHELL
  564. X#       I don't have to tell you...
  565. X#
  566. X# COPY
  567. X#       Your local copy program.  SCO Xenix users may want to change this
  568. X#       to "copy -m" which preserves file modification time.
  569. X#
  570. X# SHAR
  571. X#       Your local sharchive generator.
  572. X#
  573. X# CFLAGS
  574. X#       Compile-time flags to cc.
  575. X#       For BSD systems, include "-DBSD".
  576. X#       For USG (System III and System V) systems, include "-DUSG".
  577. X#
  578. X# LDFLAGS
  579. X#       Link-time flags to cc.  The -i flag creates pure (sharable) code.
  580. X#
  581. X# LIBS
  582. X#       Depending on your environment, you may or may not need to link
  583. X#       with "-lx".  SCO Xenix System V needs it; Altos Xenix doesn't.
  584. X#
  585. X# BIN
  586. X#       Target directory for installation; /usr/bin is recommended.
  587. X#       You may use /usr/local/bin (or whatever), but you must be sure
  588. X#       that the directory you choose is in your PATH during mail
  589. X#       transmission and delivery.
  590. X#
  591. X# DELSHAR
  592. X#       Basename of sharchives created by "make shar".
  593. X#
  594. X
  595. XSHELL = /bin/sh
  596. XCOPY =  cp
  597. XSHAR =  shar
  598. XCFLAGS = -O
  599. XLDFLAGS = -i
  600. XLIBS = -lx
  601. XBIN =   /usr/bin
  602. XDELSHAR =  deliver.sh
  603. X
  604. X#
  605. X# The files that make up the deliver distribution.
  606. X#
  607. X
  608. XDOCS =  README deliver.8
  609. XMF   =  Makefile
  610. X
  611. XHDRS =  config.h context.h deliver.h dest.h patchlevel.h misc.h
  612. X
  613. XDELSRC1 = context.c copymsg.c
  614. XDELSRC2 = debug.c dest.c dfile.c lock.c main.c
  615. XDELSRC3 = mbox.c procs.c subs.c sysdep.c unctime.y uucp.c
  616. XDELSRCS = $(DELSRC1) $(DELSRC2) $(DELSRC3)
  617. XUIDSRCS = uid.c
  618. XHDRSRCS = header.c
  619. XCOMSRCS = getopt.c
  620. XSAMPLES = samples samples/*
  621. X
  622. XDELOBJS = context.o copymsg.o debug.o dest.o dfile.o lock.o \
  623. X      main.o mbox.o procs.o subs.o sysdep.o unctime.o uucp.o
  624. XUIDOBJS = uid.o
  625. XHDROBJS = header.o
  626. XCOMOBJS = getopt.o
  627. X
  628. X#
  629. X# For GNU Make.  Sorry about the ugliness.
  630. X#
  631. X
  632. X.PHONY: all install lint shar clean clobber
  633. X
  634. X#
  635. X# The default target.
  636. X#
  637. X
  638. Xall: deliver header uid
  639. X
  640. X#
  641. X# "make clobber" implies "make clean".
  642. X#
  643. X
  644. Xclobber:: clean
  645. X
  646. X#
  647. X# How to install deliver and associated utilities.
  648. X#
  649. X
  650. Xinstall: deliver header uid
  651. X    @if [ `./uid -uU | fgrep '(root)' | wc -l` -ne 2 ]; \
  652. X    then \
  653. X        echo "Sorry!  You must be root to install deliver."; \
  654. X        exit 1; \
  655. X    fi
  656. X    $(COPY) deliver $(BIN)/deliver
  657. X    chgrp root $(BIN)/deliver
  658. X    chown root $(BIN)/deliver
  659. X    chmod 4711 $(BIN)/deliver
  660. X    $(COPY) header $(BIN)/header
  661. X    chmod 755 $(BIN)/header
  662. X
  663. X#
  664. X# How to compile and link the program.
  665. X#
  666. X
  667. Xdeliver: $(DELOBJS) $(COMOBJS)
  668. X    $(CC) $(LDFLAGS) -o $@ $(DELOBJS) $(COMOBJS) $(LIBS)
  669. X$(DELOBJS): $(HDRS)
  670. X
  671. Xclean::
  672. X    rm -f $(DELOBJS)
  673. Xclobber::
  674. X    rm -f deliver
  675. X
  676. X#
  677. X# A header parsing program.
  678. X#
  679. X
  680. Xheader: $(HDRSRCS) $(COMOBJS)
  681. X    $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(HDRSRCS) $(COMOBJS) $(LIBS)
  682. X    rm -f $(HDROBJS)
  683. X
  684. Xclobber::
  685. X    rm -f header
  686. X
  687. X#
  688. X# A little program to check on user and group id's.
  689. X# (I wish that the System V "id" program were available everywhere.)
  690. X#
  691. X
  692. Xuid: $(UIDSRCS) $(COMOBJS) config.h
  693. X    $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(UIDSRCS) $(COMOBJS) $(LIBS)
  694. X    rm -f $(UIDOBJS)
  695. X
  696. Xclobber::
  697. X    rm -f uid
  698. X
  699. X#
  700. X# Common subroutines
  701. X#
  702. X
  703. X$(COMOBJS): config.h
  704. X
  705. Xclean::
  706. X    rm -f $(COMOBJS)
  707. X
  708. X#
  709. X# Look for fuzz.
  710. X#
  711. X
  712. Xlint: deliver.lint uid.lint
  713. X
  714. Xdeliver.lint: $(HDRS) $(DELSRCS) $(COMSRCS)
  715. X    lint $(DELSRCS) $(COMSRCS) -lc $(LIBS) >$@
  716. X
  717. Xuid.lint: config.h $(UIDSRCS) $(COMSRCS)
  718. X    lint $(UIDSRCS) $(COMSRCS) -lc $(LIBS) >$@
  719. X
  720. Xclean::
  721. X    rm -f *.lint
  722. X
  723. X#
  724. X# Make distribution sharchives.
  725. X#
  726. X
  727. Xshar:   $(DELSHAR).01 $(DELSHAR).02 $(DELSHAR).03 $(DELSHAR).04
  728. X$(DELSHAR).01: $(DOCS) $(MF) $(UIDSRCS) $(HDRSRCS) $(COMSRCS) $(SAMPLES)
  729. X    $(SHAR) >$@ $(DOCS) $(MF) $(UIDSRCS) $(HDRSRCS) $(COMSRCS) $(SAMPLES)
  730. X$(DELSHAR).02: $(HDRS) $(DELSRC1)
  731. X    $(SHAR) >$@ $(HDRS) $(DELSRC1)
  732. X$(DELSHAR).03: $(DELSRC2)
  733. X    $(SHAR) >$@ $(DELSRC2)
  734. X$(DELSHAR).04: $(DELSRC3)
  735. X    $(SHAR) >$@ $(DELSRC3)
  736. X
  737. Xclobber::
  738. X    rm -f $(DELSHAR).??
  739. END_OF_FILE
  740. if test 4306 -ne `wc -c <'Makefile'`; then
  741.     echo shar: \"'Makefile'\" unpacked with wrong size!
  742. fi
  743. # end of 'Makefile'
  744. fi
  745. if test -f 'uid.c' -a "${1}" != "-c" ; then 
  746.   echo shar: Will not clobber existing file \"'uid.c'\"
  747. else
  748. echo shar: Extracting \"'uid.c'\" \(2772 characters\)
  749. sed "s/^X//" >'uid.c' <<'END_OF_FILE'
  750. X/* $Header: uid.c,v 2.1 89/06/09 12:25:41 network Exp $
  751. X *
  752. X * I wish the System V "id" program were universally available; but it
  753. X * isn't, so I've written this replacement.
  754. X *
  755. X * usage: uid [-options]
  756. X *
  757. X * Default action is to print one line in the manner of "id":
  758. X *      uid=201(chip) gid=50(group) euid=0(root) egid=0(root)
  759. X * (Note that the "euid" and "egid" entries are not output if they are
  760. X * the same as the "uid" and "gid" values.)
  761. X *
  762. X * If an option string is specified, it disables the normal behavior in
  763. X * favor of displaying id information, one per line, in the order that
  764. X * the options appear in the option string.  Legal options are:
  765. X *      u       real uid
  766. X *      g       real gid
  767. X *      U       effective uid
  768. X *      G       effective gid
  769. X *
  770. X * NOTE: This program is not a paragon of good style.
  771. X *       It's just something I needed for a Makefile.
  772. X *
  773. X * $Log:    uid.c,v $
  774. X * Revision 2.1  89/06/09  12:25:41  network
  775. X * Update RCS revisions.
  776. X * 
  777. X * Revision 1.3  89/06/09  12:24:00  network
  778. X * Baseline for 2.0 release.
  779. X * 
  780. X */
  781. X
  782. X#include <stdio.h>
  783. X#include <pwd.h>
  784. X#include <grp.h>
  785. X#include "config.h"
  786. X
  787. X#ifdef NULL
  788. X#undef NULL
  789. X#endif
  790. X#define NULL 0
  791. X
  792. Xextern  struct passwd   *getpwuid();
  793. Xextern  struct group    *getgrgid();
  794. X
  795. Xchar    *progname = "uid";
  796. X
  797. Xchar    *uid_desc();
  798. Xchar    *gid_desc();
  799. X
  800. Xmain(argc, argv)
  801. Xint     argc;
  802. Xchar    **argv;
  803. X{
  804. X    int     uid, gid, euid, egid;
  805. X    int     c, lines, errcount;
  806. X
  807. X    uid = getuid();
  808. X    gid = getgid();
  809. X    euid = geteuid();
  810. X    egid = getegid();
  811. X
  812. X    errcount = 0;
  813. X    lines = 0;
  814. X
  815. X    while ((c = getopt(argc, argv, "ugUG")) != EOF)
  816. X    {
  817. X        switch (c)
  818. X        {
  819. X        case 'u':
  820. X            (void) printf("%s\n", uid_desc(uid));
  821. X            ++lines;
  822. X            break;
  823. X
  824. X        case 'g':
  825. X            (void) printf("%s\n", gid_desc(gid));
  826. X            ++lines;
  827. X            break;
  828. X
  829. X        case 'U':
  830. X            (void) printf("%s\n", uid_desc(euid));
  831. X            ++lines;
  832. X            break;
  833. X
  834. X        case 'G':
  835. X            (void) printf("%s\n", gid_desc(egid));
  836. X            ++lines;
  837. X            break;
  838. X
  839. X        case '?':
  840. X            ++errcount;
  841. X            break;
  842. X        }
  843. X    }
  844. X
  845. X    if (errcount)
  846. X    {
  847. X        (void) fprintf(stderr, "usage: uid [-ugUG]\n");
  848. X        exit(1);
  849. X    }
  850. X
  851. X    if (lines == 0)
  852. X    {
  853. X        (void) printf("uid=%s", uid_desc(uid));
  854. X        (void) printf(" gid=%s", gid_desc(gid));
  855. X
  856. X        if (euid != uid)
  857. X            (void) printf(" euid=%s", uid_desc(euid));
  858. X        if (egid != gid)
  859. X            (void) printf(" egid=%s", gid_desc(egid));
  860. X
  861. X        (void) printf("\n");
  862. X    }
  863. X
  864. X    exit(0);
  865. X    /* NOTREACHED */
  866. X}
  867. X
  868. Xchar *
  869. Xuid_desc(uid)
  870. Xint     uid;
  871. X{
  872. X    struct passwd *pw;
  873. X    static char buf[80];
  874. X
  875. X    (void) sprintf(buf, "%d", uid);
  876. X    if ((pw = getpwuid(uid)) != NULL)
  877. X        (void) sprintf(buf + strlen(buf), "(%s)", pw->pw_name);
  878. X
  879. X    return buf;
  880. X}
  881. X
  882. Xchar *
  883. Xgid_desc(gid)
  884. Xint     gid;
  885. X{
  886. X    struct group *gr;
  887. X    static char buf[80];
  888. X
  889. X    (void) sprintf(buf, "%d", gid);
  890. X    if ((gr = getgrgid(gid)) != NULL)
  891. X        (void) sprintf(buf + strlen(buf), "(%s)", gr->gr_name);
  892. X
  893. X    return buf;
  894. X}
  895. END_OF_FILE
  896. if test 2772 -ne `wc -c <'uid.c'`; then
  897.     echo shar: \"'uid.c'\" unpacked with wrong size!
  898. fi
  899. # end of 'uid.c'
  900. fi
  901. if test -f 'header.c' -a "${1}" != "-c" ; then 
  902.   echo shar: Will not clobber existing file \"'header.c'\"
  903. else
  904. echo shar: Extracting \"'header.c'\" \(4796 characters\)
  905. sed "s/^X//" >'header.c' <<'END_OF_FILE'
  906. X/* $Header: header.c,v 2.2 89/06/09 13:08:07 network Exp $
  907. X *
  908. X * A program to parse RFC 822 mail/news headers.
  909. X *
  910. X * usage: header [-c] [-n] [-f field] ... files
  911. X *
  912. X * Default action is to print entire header.  If one or more -f options
  913. X * are given, only the specified fields are printed.  The field names are
  914. X * not printed unless -n is specified.  Field name comparisons are case
  915. X * insensitive unless -c is specified.
  916. X *
  917. X * Output lines are preceeded by the filename if more than one file is
  918. X * specified.
  919. X *
  920. X * This program is intended for use in delivery files, to extract multi-
  921. X * line header fields.
  922. X *
  923. X * $Log:    header.c,v $
  924. X * Revision 2.2  89/06/09  13:08:07  network
  925. X * Adapt to BSD quirks.
  926. X * 
  927. X * Revision 2.1  89/06/09  12:25:29  network
  928. X * Update RCS revisions.
  929. X * 
  930. X * Revision 1.5  89/06/09  12:23:51  network
  931. X * Baseline for 2.0 release.
  932. X * 
  933. X */
  934. X
  935. X#include <stdio.h>
  936. X#include <ctype.h>
  937. X
  938. X/*
  939. X * Manifest constants
  940. X */
  941. X
  942. X#define TRUE 1
  943. X#define FALSE 0
  944. X
  945. X/*
  946. X * Other useful macros.
  947. X */
  948. X
  949. X#define GETSIZE(buf)    (sizeof(buf) - 1)
  950. X
  951. X#define ISFROM(p) ((p)[0] == 'F' && (p)[1] == 'r' && (p)[2] == 'o' \
  952. X        && (p)[3] == 'm' && (p)[4] == ' ')
  953. X
  954. X/*
  955. X * External data.
  956. X */
  957. X
  958. X/* Variables set by getopt() [blech] */
  959. X
  960. Xextern  int     optind, opterr;
  961. Xextern  char    *optarg;
  962. X
  963. X/*
  964. X * Library functions.
  965. X */
  966. X
  967. Xextern  char    *malloc();
  968. Xextern  char    *realloc();
  969. Xextern  void    free();
  970. X
  971. X/*
  972. X * Global data
  973. X */
  974. X
  975. Xint     field_count     = 0;
  976. Xint     field_alloc     = 0;
  977. Xchar    **field_names   = NULL;
  978. X
  979. Xint     nocasematch     = TRUE;         /* ignore case in header matches */
  980. Xint     printnames      = FALSE;        /* print field names with data */
  981. X
  982. X/*----------------------------------------------------------------------
  983. X * The Program.
  984. X */
  985. X
  986. Xmain(argc, argv)
  987. Xint     argc;
  988. Xchar    **argv;
  989. X{
  990. X    int     c, errors;
  991. X
  992. X    field_alloc = 8;
  993. X    field_names = (char **) malloc(field_alloc * sizeof(char **));
  994. X    if (field_names == NULL)
  995. X        nomem();
  996. X
  997. X    errors = FALSE;
  998. X    while ((c = getopt(argc, argv, "cnf:")) != EOF)
  999. X    {
  1000. X        switch (c)
  1001. X        {
  1002. X        case 'c':
  1003. X            nocasematch = FALSE;
  1004. X            break;
  1005. X        case 'n':
  1006. X            printnames = TRUE;
  1007. X            break;
  1008. X        case 'f':
  1009. X            if (field_count >= field_alloc)
  1010. X            {
  1011. X                field_alloc *= 2;
  1012. X                field_names =
  1013. X                    (char **) realloc((char *)field_names,
  1014. X                          field_alloc * sizeof(char **));
  1015. X                if (field_names == NULL)
  1016. X                    nomem();
  1017. X            }
  1018. X            field_names[field_count++] = optarg;
  1019. X            break;
  1020. X        default:
  1021. X            errors = TRUE;
  1022. X            break;
  1023. X        }
  1024. X    }
  1025. X
  1026. X    if (errors)
  1027. X        usage();
  1028. X
  1029. X    if (optind == argc)
  1030. X        header(stdin, (char *)NULL);
  1031. X    else
  1032. X    {
  1033. X        FILE    *fp;
  1034. X        int     a, filenames;
  1035. X
  1036. X        filenames = ((argc - optind) > 1);
  1037. X        for (a = optind; a < argc; ++a)
  1038. X        {
  1039. X            if ((fp = fopen(argv[a], "r")) == NULL)
  1040. X            {
  1041. X                errors = TRUE;
  1042. X                perror(argv[a]);
  1043. X                continue;
  1044. X            }
  1045. X
  1046. X            header(fp, (filenames ? argv[a] : (char *)NULL));
  1047. X            fclose(fp);
  1048. X        }
  1049. X    }
  1050. X
  1051. X    exit(errors ? 1 : 0);
  1052. X}
  1053. X
  1054. Xusage()
  1055. X{
  1056. X    fprintf(stderr, "usage: header [-c] [-f fieldname] ... files\n");
  1057. X    exit(1);
  1058. X}
  1059. X
  1060. Xnomem()
  1061. X{
  1062. X    fprintf(stderr, "header: out of memory\n");
  1063. X    exit(1);
  1064. X}
  1065. X
  1066. Xheader(fp, filename)
  1067. XFILE    *fp;
  1068. Xchar    *filename;
  1069. X{
  1070. X    char    buf[1024];
  1071. X
  1072. X    if (fgets(buf, GETSIZE(buf), fp) == NULL)
  1073. X        return;
  1074. X
  1075. X    /* Ignore From_ line(s). */
  1076. X
  1077. X    while (ISFROM(buf) || buf[0] == '>')
  1078. X    {
  1079. X        if (fgets(buf, GETSIZE(buf), fp) == NULL)
  1080. X            return;
  1081. X    }
  1082. X
  1083. X    while (buf[0] != '\n')
  1084. X    {
  1085. X        char    *p;
  1086. X        int     print_this;
  1087. X
  1088. X        p = buf;
  1089. X        while (isupper(*p) || islower(*p) || isdigit(*p) || *p == '-')
  1090. X            ++p;
  1091. X        if (p == buf || *p != ':')
  1092. X            break;
  1093. X        print_this = field(buf, p - buf);
  1094. X        if (print_this)
  1095. X        {
  1096. X            if (filename)
  1097. X            {
  1098. X                fputs(filename, stdout);
  1099. X                putc(':', stdout);
  1100. X            }
  1101. X            ++p;
  1102. X            if (*p == ' ' || *p == '\t')
  1103. X                ++p;
  1104. X            if (field_count == 0 || printnames)
  1105. X                fputs(buf, stdout);
  1106. X            else
  1107. X                fputs(p, stdout);
  1108. X        }
  1109. X
  1110. X        /* get the next input line */
  1111. X        if (fgets(buf, GETSIZE(buf), fp) == NULL)
  1112. X            break;
  1113. X
  1114. X        /* deal with continuation lines */
  1115. X        while (buf[0] == ' ' || buf[0] == '\t')
  1116. X        {
  1117. X            if (print_this)
  1118. X            {
  1119. X                if (filename)
  1120. X                {
  1121. X                    fputs(filename, stdout);
  1122. X                    putc(':', stdout);
  1123. X                }
  1124. X                fputs(buf, stdout);
  1125. X            }
  1126. X
  1127. X            if (fgets(buf, GETSIZE(buf), fp) == NULL)
  1128. X            {
  1129. X                buf[0] = '\n';
  1130. X                break;
  1131. X            }
  1132. X        }
  1133. X    }
  1134. X}
  1135. X
  1136. Xint
  1137. Xfield(s, n)
  1138. Xchar    *s;
  1139. Xint     n;
  1140. X{
  1141. X    int     i;
  1142. X
  1143. X    if (field_count == 0)
  1144. X        return TRUE;
  1145. X
  1146. X    for (i = 0; i < field_count; ++i)
  1147. X    {
  1148. X        char    *f = field_names[i];
  1149. X
  1150. X        if (strlen(f) == n)
  1151. X        {
  1152. X            if (nocasematch)
  1153. X            {
  1154. X                if (ci_strncmp(f, s, n) == 0)
  1155. X                    return TRUE;
  1156. X            }
  1157. X            else
  1158. X            {
  1159. X                if (strncmp(f, s, n) == 0)
  1160. X                    return TRUE;
  1161. X            }
  1162. X        }
  1163. X    }
  1164. X
  1165. X    return FALSE;
  1166. X}
  1167. X
  1168. Xint
  1169. Xci_strncmp(s, t, n)
  1170. Xchar    *s, *t;
  1171. Xint     n;
  1172. X{
  1173. X    char    c, d;
  1174. X
  1175. X    while (n-- > 0)
  1176. X    {
  1177. X        c = *s++;
  1178. X        d = *t++;
  1179. X        if ((c == 0) && (d == 0))
  1180. X            break;
  1181. X        if (isupper(c))
  1182. X            c = tolower(c);
  1183. X        if (isupper(d))
  1184. X            d = tolower(d);
  1185. X        if (c > d)
  1186. X            return 1;
  1187. X        if (c < d)
  1188. X            return -1;
  1189. X    }
  1190. X
  1191. X    return 0;
  1192. X}
  1193. END_OF_FILE
  1194. if test 4796 -ne `wc -c <'header.c'`; then
  1195.     echo shar: \"'header.c'\" unpacked with wrong size!
  1196. fi
  1197. # end of 'header.c'
  1198. fi
  1199. if test -f 'getopt.c' -a "${1}" != "-c" ; then 
  1200.   echo shar: Will not clobber existing file \"'getopt.c'\"
  1201. else
  1202. echo shar: Extracting \"'getopt.c'\" \(1719 characters\)
  1203. sed "s/^X//" >'getopt.c' <<'END_OF_FILE'
  1204. X/* $Header: getopt.c,v 2.1 89/06/09 12:25:28 network Exp $
  1205. X *
  1206. X * A version of the public-domain getopt() function, as found
  1207. X * in the SVID and fine Unix manuals everywhere.
  1208. X *
  1209. X * $Log:    getopt.c,v $
  1210. X * Revision 2.1  89/06/09  12:25:28  network
  1211. X * Update RCS revisions.
  1212. X * 
  1213. X * Revision 1.4  89/06/09  12:23:50  network
  1214. X * Baseline for 2.0 release.
  1215. X * 
  1216. X */
  1217. X
  1218. X#include <stdio.h>
  1219. X#include "config.h"
  1220. X#include "misc.h"
  1221. X
  1222. X/*----------------------------------------------------------------------
  1223. X * Get command line options.
  1224. X * This is essentially the public domain version, just reformatted to
  1225. X * match the rest of the deliver program.
  1226. X */
  1227. X
  1228. X#ifndef HAS_GETOPT
  1229. X
  1230. Xint     opterr = 1;
  1231. Xint     optind = 1;
  1232. Xint     optopt = 0;
  1233. Xchar    *optarg = NULL;
  1234. X
  1235. X#define ERR(what,c) \
  1236. X    if (!opterr) {} else fprintf(stderr,"%s: %s -- %c\n", argv[0], what, c);
  1237. X
  1238. Xint
  1239. Xgetopt(argc, argv, opts)
  1240. Xint argc;
  1241. Xchar **argv;
  1242. Xchar *opts;
  1243. X{
  1244. X    static int sp = 1;
  1245. X    int c;
  1246. X    char *cp;
  1247. X
  1248. X    if (sp == 1)
  1249. X    {
  1250. X        if (optind >= argc
  1251. X         || argv[optind][0] != '-' || argv[optind][1] == '\0')
  1252. X            return EOF;
  1253. X
  1254. X        if (strcmp(argv[optind], "--") == NULL)
  1255. X        {
  1256. X            optind++;
  1257. X            return EOF;
  1258. X        }
  1259. X    }
  1260. X
  1261. X    optopt = c = argv[optind][sp];
  1262. X
  1263. X    if (c == ':' || (cp = strchr(opts, c)) == NULL)
  1264. X    {
  1265. X        ERR("illegal option", c);
  1266. X        if (argv[optind][++sp] == '\0')
  1267. X        {
  1268. X            optind++;
  1269. X            sp = 1;
  1270. X        }
  1271. X        return '?';
  1272. X    }
  1273. X
  1274. X    if (*++cp == ':')
  1275. X    {
  1276. X        if (argv[optind][sp + 1] != '\0')
  1277. X            optarg = &argv[optind++][sp + 1];
  1278. X        else if (++optind >= argc)
  1279. X        {
  1280. X            ERR("option requires an argument", c);
  1281. X            sp = 1;
  1282. X            return '?';
  1283. X        }
  1284. X        else
  1285. X            optarg = argv[optind++];
  1286. X
  1287. X        sp = 1;
  1288. X    }
  1289. X    else
  1290. X    {
  1291. X        if (argv[optind][++sp] == '\0')
  1292. X        {
  1293. X            sp = 1;
  1294. X            optind++;
  1295. X        }
  1296. X
  1297. X        optarg = NULL;
  1298. X    }
  1299. X
  1300. X    return c;
  1301. X}
  1302. X
  1303. X#endif  /* !HAS_GETOPT */
  1304. END_OF_FILE
  1305. if test 1719 -ne `wc -c <'getopt.c'`; then
  1306.     echo shar: \"'getopt.c'\" unpacked with wrong size!
  1307. fi
  1308. # end of 'getopt.c'
  1309. fi
  1310. if test ! -d 'samples' ; then
  1311.     echo shar: Creating directory \"'samples'\"
  1312.     mkdir 'samples'
  1313. fi
  1314. if test -f 'samples/README' -a "${1}" != "-c" ; then 
  1315.   echo shar: Will not clobber existing file \"'samples/README'\"
  1316. else
  1317. echo shar: Extracting \"'samples/README'\" \(229 characters\)
  1318. sed "s/^X//" >'samples/README' <<'END_OF_FILE'
  1319. XREADME for samples.
  1320. X
  1321. XThese sample delivery file are provides for your edification and amusement.
  1322. XI've actually tested u-chip and u-vacation; the other samples are just off
  1323. Xthe top of my head.  Use at your own risk, and all that.
  1324. END_OF_FILE
  1325. if test 229 -ne `wc -c <'samples/README'`; then
  1326.     echo shar: \"'samples/README'\" unpacked with wrong size!
  1327. fi
  1328. # end of 'samples/README'
  1329. fi
  1330. if test -f 'samples/p-aliases' -a "${1}" != "-c" ; then 
  1331.   echo shar: Will not clobber existing file \"'samples/p-aliases'\"
  1332. else
  1333. echo shar: Extracting \"'samples/p-aliases'\" \(445 characters\)
  1334. sed "s/^X//" >'samples/p-aliases' <<'END_OF_FILE'
  1335. X: p-aliases
  1336. X# A sample post-user deliver file.
  1337. X#
  1338. X# This post-user delivery file provides system-wide aliases that are
  1339. X# processed after user delivery files have had their say.
  1340. X
  1341. Xfor u
  1342. Xdo
  1343. X    case $u in
  1344. X    root)       echo buoc ;;                # Big User On Computer :-)
  1345. X    uucp)       echo buoc ;;
  1346. X    postmaster) echo buoc ;;
  1347. X    bug-alias)  echo user1; echo user2 ;;   # Both users get each message
  1348. X    *)          echo $u ;;
  1349. X    esac
  1350. Xdone
  1351. END_OF_FILE
  1352. if test 445 -ne `wc -c <'samples/p-aliases'`; then
  1353.     echo shar: \"'samples/p-aliases'\" unpacked with wrong size!
  1354. fi
  1355. # end of 'samples/p-aliases'
  1356. fi
  1357. if test -f 'samples/s-aliases' -a "${1}" != "-c" ; then 
  1358.   echo shar: Will not clobber existing file \"'samples/s-aliases'\"
  1359. else
  1360. echo shar: Extracting \"'samples/s-aliases'\" \(653 characters\)
  1361. sed "s/^X//" >'samples/s-aliases' <<'END_OF_FILE'
  1362. X: s-aliases
  1363. X# A sample system delivery file.
  1364. X#
  1365. X# While Joe is gone, send problem reports to Fred.
  1366. X# Note that since user delivery files are processed after this one,
  1367. X#    Fred's user delivery file may direct all such mail back to joe
  1368. X#    if Fred wants to be difficult. :-)
  1369. X# Note that a better solution is to use a bug report alias,
  1370. X#    but this method demonstrates variable delivery based
  1371. X#    on message headers.
  1372. X
  1373. XSUBJECT=`header -f subject $HEADER | tr '[A-Z]' '[a-z]'`
  1374. X
  1375. Xfor u
  1376. Xdo
  1377. X    case $u in
  1378. X    joe)        case $SUBJECT in
  1379. X        *bug*|*problem*)    echo fred ;;
  1380. X        *)                  echo joe ;;
  1381. X        esac ;;
  1382. X    *)          echo $u ;;
  1383. X    esac
  1384. Xdone
  1385. END_OF_FILE
  1386. if test 653 -ne `wc -c <'samples/s-aliases'`; then
  1387.     echo shar: \"'samples/s-aliases'\" unpacked with wrong size!
  1388. fi
  1389. # end of 'samples/s-aliases'
  1390. fi
  1391. if test -f 'samples/u-chip' -a "${1}" != "-c" ; then 
  1392.   echo shar: Will not clobber existing file \"'samples/u-chip'\"
  1393. else
  1394. echo shar: Extracting \"'samples/u-chip'\" \(247 characters\)
  1395. sed "s/^X//" >'samples/u-chip' <<'END_OF_FILE'
  1396. X: u-chip
  1397. X# Chip's user delivery file.
  1398. X
  1399. Xuser="$1"
  1400. XTO=`header -f To -f CC $HEADER`
  1401. X
  1402. Xcase "$SENDER" in
  1403. X*zardoz*!sec*)  echo $user:mbox.sec;   exit ;;
  1404. Xesac
  1405. X
  1406. Xcase "$TO" in
  1407. X*ietf*|*ineng*) echo $user:mbox.ietf;   exit ;;
  1408. Xesac
  1409. X
  1410. X# Default case
  1411. Xecho $user
  1412. END_OF_FILE
  1413. if test 247 -ne `wc -c <'samples/u-chip'`; then
  1414.     echo shar: \"'samples/u-chip'\" unpacked with wrong size!
  1415. fi
  1416. # end of 'samples/u-chip'
  1417. fi
  1418. if test -f 'samples/u-vacation' -a "${1}" != "-c" ; then 
  1419.   echo shar: Will not clobber existing file \"'samples/u-vacation'\"
  1420. else
  1421. echo shar: Extracting \"'samples/u-vacation'\" \(1033 characters\)
  1422. sed "s/^X//" >'samples/u-vacation' <<'END_OF_FILE'
  1423. X: u-vacation
  1424. X# A user delivery file for when you're on vacation.
  1425. X#
  1426. X# The ALREADY file remembers who you've already mailed vacation messages to.
  1427. X# The BEBACK string is the date you will return.
  1428. X
  1429. XALREADY=vacation.list
  1430. XBEBACK="on July 4, 1776"
  1431. X
  1432. Xecho "$1"               # Keep the mail!
  1433. X
  1434. Xif grep '^'${SENDER}'$' $ALREADY >/dev/null 2>/dev/null
  1435. Xthen
  1436. X    exit 0              # We already notified this person; reject
  1437. Xfi
  1438. X
  1439. Xcase $SENDER in
  1440. X*uucp)  exit 0 ;;       # Not a human; reject
  1441. X*daemon) exit 0 ;;      # Not a human; reject
  1442. X*DAEMON) exit 0 ;;      # Not a human; reject
  1443. X*!*)    ;;
  1444. X*@*)    ;;
  1445. X## *)      exit 0 ;;       # Local user; reject (maybe)
  1446. Xesac
  1447. X
  1448. X# Remember this person
  1449. Xecho $SENDER >>$ALREADY
  1450. X
  1451. X# Send the vacation message
  1452. XSUBJECT=`header -f subject $HEADER`
  1453. Xmail -s "I'm on vacation" $SENDER <<!EOF!
  1454. XYour message to me on the subject
  1455. X    "$SUBJECT"
  1456. Xhas been delivered.  However, I am on vacation, so I have not yet
  1457. Xread your message.  I will be back $BEBACK.
  1458. X
  1459. XThis is the only such message you will receive.
  1460. X
  1461. XThank you.
  1462. X!EOF!
  1463. END_OF_FILE
  1464. if test 1033 -ne `wc -c <'samples/u-vacation'`; then
  1465.     echo shar: \"'samples/u-vacation'\" unpacked with wrong size!
  1466. fi
  1467. # end of 'samples/u-vacation'
  1468. fi
  1469. echo shar: End of shell archive.
  1470. exit 0
  1471.  
  1472.  
  1473.